package ru.papergames.web.services;

import org.hibernate.Session;
import ru.common.hibernate.HibernateAction;
import ru.papergames.common.form.NpcPlayerForm;
import ru.papergames.common.model.NpcPlayer;

import java.util.ArrayList;
import java.util.List;

/**
 * Date: 12.05.12 9:21
 *
 * @author Alexander Troshanin
 */
public class GetNpcPlayers implements HibernateAction<List<NpcPlayerForm>> {

    @Override
    public List<NpcPlayerForm> execute(Session session) {
        List<NpcPlayer> npcPlayers = session.createCriteria(NpcPlayer.class).list();
        List<NpcPlayerForm> result = new ArrayList<NpcPlayerForm>(npcPlayers.size());
        for (NpcPlayer npcPlayer : npcPlayers) {
            result.add(new NpcPlayerForm(npcPlayer));
        }
        return result;
    }

}
